<include file="Common/header" />
<!-- 顶部 -->     
<div id="middle">
    <include file="Common/menu" />
    <div class="right" id="mainFrame">
		<div class="right_cont">
			<ul class="breadcrumb">当前位置：
				<a href="javascript:void(0);">首页</a> <span class="divider">/</span>
				<a href="javascript:void(0);">财务管理</a> <span class="divider">/</span>
				退房管理
			</ul>
			<div class="title_right"><strong>按条件查询</strong></div>
			<form action="" method="POST" id="addfrom">
				<div style="width: 900px; margin:auto">
					<table class="table table-bordered">
						<tr>
							<td width="20%" align="right" bgcolor="#f1f1f1">房间号：</td>
							<td width="30%">
								<input type="text" name="room_number" id="room_number" class="span1-3" value="" />
								<span class="usernameabel"></span>
							</td>
							<td align="left">
								<input type="button" value="查询" class="btn btn-info querys" style="width:80px;" />
								<input type="button" value="导出Excel" class="btn btn-danger" style="width:80px; display: none;" />
							</td>
						</tr>
						
					</table>
				</div>
			</form>
			<div class="title_right"><strong>会员信息</strong></div>
			<div style="width: 900px; margin:auto">
				<table class="table table-bordered">
					<tr>
						<td width="20%" align="right" bgcolor="#f1f1f1">姓名：</td>
						<td width="30%">
							<input type="text" name="field1" id="field1" class="span1-3" value="" />
						</td>
						<td width="20%" align="right" bgcolor="#f1f1f1">合同号：</td>
						<td width="30%">
							<input type="text" name="field2" id="field2" class="span1-3" value="" />
						</td>
					</tr>
					<tr>
						<td width="20%" align="right" bgcolor="#f1f1f1">合同开始时间：</td>
						<td width="30%">
							<input type="text" name="field3" id="field3" class="span1-3" value="" />
						</td>
						<td width="20%" align="right" bgcolor="#f1f1f1">合同结束时间：</td>
						<td width="30%">
							<input type="text" name="field4" id="field4" class="span1-3" value="" />
						</td>
					</tr>
				</table>
			</div>
			<div class="title_right"><strong>退房费用详情</strong></div>
			<div>
				<table class="table table-bordered"> 
					<tr>
						<td width="10%" align="right" bgcolor="#f1f1f1">押金：</td>
						<td width="20%">
							<input type="text" name="deposit" id="deposit" class="span1-3 keyups" value="0" />
							<span class="usernameabel">元</span>
							<div class="div_right">
								<input type="checkbox" attkey="deposit" name="parentCheckBox" id="parentCheckBox" class="nodeCheckbox nodeCheckbox_1" parent_id="1" style="vertical-align:middle; float: left;" value="1" checked />&nbsp;&nbsp;
							</div>
						</td>
						
						<td width="10%" align="right" bgcolor="#f1f1f1">房租：</td>
						<td width="20%">
							<input type="text" name="rent" id="rent" class="span1-3 keyups" value="0" />
							<span class="usernameabel">元</span>
							<div class="div_right">
								<input type="checkbox" attkey="rent" name="parentCheckBox" id="parentCheckBox" class="nodeCheckbox nodeCheckbox_1" parent_id="1" style="vertical-align:middle; float: left;" value="1" checked />&nbsp;&nbsp;
							</div>
						</td>
						
						<td width="10%" align="right" bgcolor="#f1f1f1">物业费：</td>
						<td width="20%">
							<input type="text" name="property" id="property" class="span1-3 keyups" value="0" />
							<span class="usernameabel">元</span>
							<div class="div_right">
								<input type="checkbox" attkey="property" name="parentCheckBox" id="parentCheckBox" class="nodeCheckbox nodeCheckbox_1" parent_id="1" style="vertical-align:middle; float: left;" value="1" checked />&nbsp;&nbsp;
							</div>
						</td>
					</tr>
					<tr>
						<td width="10%" align="right" bgcolor="#f1f1f1">定金：</td>
						<td width="20%">
							<input type="text" name="deposit_first" id="deposit_first" class="span1-3 keyups" value="0" />
							<span class="usernameabel">元</span>
							<div class="div_right">
								<input type="checkbox" attkey="deposit_first" name="parentCheckBox" id="parentCheckBox" class="nodeCheckbox nodeCheckbox_1" parent_id="1" style="vertical-align:middle; float: left;" value="1" checked />&nbsp;&nbsp;
							</div>
						</td>
					
						<td width="10%" align="right" bgcolor="#f1f1f1">水电气余额：</td>
						<td width="20%">
							<input type="text" name="water_power" id="water_power" class="span1-3 keyups" value="0" />
							<span class="usernameabel">元</span>
							<div class="div_right">
								<input type="checkbox" attkey="water_power" name="parentCheckBox" id="parentCheckBox" class="nodeCheckbox nodeCheckbox_1" parent_id="1" style="vertical-align:middle; float: left;" value="1" checked />&nbsp;&nbsp;
							</div>
						</td>
						
						<td width="10%" align="right" bgcolor="#f1f1f1">其他：</td>
						<td width="20%">
							<input type="text" name="other" id="other" class="span1-3 keyups" value="0" />
							<span class="usernameabel">元</span>
							<div class="div_right">
								<input type="checkbox" attkey="other" name="parentCheckBox" id="parentCheckBox" class="nodeCheckbox nodeCheckbox_1" parent_id="1" style="vertical-align:middle; float: left;" value="1" checked />&nbsp;&nbsp;
							</div>
						</td>
					</tr>
					<tr>
						<td width="10%" align="right" bgcolor="#f1f1f1">退款合计：</td>
						<td width="20%">
							<input type="text" name="acount" id="acount" class="span1-3" value="0" />
							<span class="usernameabel"></span>
						</td>
						<td width="10%" align="right" bgcolor="#f1f1f1">备注：</td>
						<td width="20%" colspan="3">
							<input type="text" name="remark" id="remark" class="span1-3" value="" />
							<span class="usernameabel"></span>
						</td>
					</tr>
					<tr>
						<td width="10%" align="right" bgcolor="#f1f1f1">退款方式：</td>
						<td width="20%" colspan="5">
							<select id="pay_type" name="pay_type">
								<option value="0">现金</option>
								<option value="1">支付宝</option>
								<option value="2">微信</option>
								<option value="3">信用卡</option>
							<select>
							<span style="padding-left: 10px;">账/卡号</span>
							<input type="text" name="pay_card" id="pay_card" class="span1-3" value="" />
							<span class="usernameabel"></span>
						</td>
					</tr>
				</table>
				<table  class="margin-bottom-20 table  no-border" >
					<tr>
						<td class="text-center">
							<input type="button" value="确定" class="btn btn-info roleSubmit" style="width:80px;" />
						</td>
					</tr>
				</table>
			</div>
			<div class="title_right"><strong>历史退房信息</strong></div>
			<div id="ajaxDiv">
				<include file="Paylog/goback_list" />
			</div>
		</div>     
    </div>
</div>
<script>
	$(document).ready(function(){
		var fromData = {};
		$(".roleSubmit").on('click', function(){
			if(fromData.contract){
				var load = layer.load(2);
				$(".keyups").each(function(){
					if($(this).closest('td').find('.nodeCheckbox').is(':checked')){
						fromData[$(this).attr('name')] = parseFloat($(this).val());
					}else{
						fromData[$(this).attr('name')] = 0;
					}
				});
				
				fromData['remark'] = $("#remark").val();
				fromData['pay_type'] = $("#pay_type").val();
				fromData['pay_card'] = $("#pay_card").val();
				
				$.post('ajaxgoback.html', {json: JSON.stringify(fromData)}, function(data){
					layer.close(load);
					layer.msg(data);
					location.reload();
				});
			}else{
				layer.msg('请先查询目标房间数据');
			}
		});
		
		$(".querys").on('click', function(){
			var load = layer.load(2);
			var room_number = $("#room_number").val();
			$.get('ajaxgoback.html', {roomnumber: room_number}, function(data){
				layer.close(load);
				if(data.errCode/1){
					fromData = data.info;
					//Set Value
					$("#deposit").val(fromData.deposit);
					$("#deposit_first").val(fromData.deposit_first);
					$("#water_power").val(fromData.water_power);
					$("#property").val(fromData.property);
					$("#rent").val(fromData.rent);
					$("#card_peposit").val(fromData.card_peposit);
					$("#acount").val(fromData.acount);
					$("#other").val(fromData.other);
					//加载会员详情
					var uinfo = data.field;
					$("#field2").val(uinfo.contract);
					$("#field1").val(uinfo.nickname);
					$("#field3").val(uinfo.begintime);
					$("#field4").val(uinfo.endtime);
					//家宅历史退房记录
					$("#ajaxDiv").html(data.html);
				}else{
					layer.msg('未查询到相关信息');
				}
			});
		});
		
		$(".nodeCheckbox").on('change', function(){
			var obj = $(this);
			var attkey = obj.attr('attkey');
			var acount = $("#acount").val()/1;
			var ncount = $("#"+ attkey).val()/1;
			
			if(obj.is(':checked')){
				acount += ncount;
			}else{
				acount -= ncount;
			}
			
			$("#acount").val(acount.toFixed(2));
		});
		
		$(".keyups").on('keyup', function(){
			var vals = $(this).val() || 0;
			try{
				vals = vals.replace(/[^\-?\d.]/g,'');
				if(vals.match(/^[\+\-]?\d*?\.?\d*?$/)){
					var attr = vals.split(".");
					if(attr.length > 1 && attr[1].length == 0){
						vals = attr[0];
					}
				}
			}catch(e){}
			$(this).val(vals/1);
			
			var acount = 0;
			$(".keyups").each(function(){
				if($(this).closest('td').find('.nodeCheckbox').is(':checked')){
					acount += parseFloat($(this).val());
				}
			});
			
			$("#acount").val(acount.toFixed(2));
		});
		
	});
</script>
<script>
!function(){
	laydate.skin('molv');
	laydate({elem: '#btime'});
	laydate({elem: '#etime'});
}();
</script>
<include file="Common/footer" />
